package com.atguigu.gulimall.cart.config;

import com.atguigu.gulimall.cart.interceptor.CartInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @create: 2024/9/6
 * @author: gyhe10
 * @description:
 **/

@Configuration
public class GulimallCartWebMvcConfig implements WebMvcConfigurer {
    // 配置视图映射，仅用于实现域名访问 cart 服务时测试
    // 后续开发中在 CartController 中通过控制器方法配置视图映射
    // @Override
    // public void addViewControllers(ViewControllerRegistry registry) {
    //     registry.addViewController("/cartList.html").setViewName("cartList");
    //     registry.addViewController("/success.html").setViewName("success");
    // }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new CartInterceptor()).addPathPatterns("/**");
    }
}
